package com.prd.controller;


import com.prd.dto.WorkContactFormDTO;
import com.prd.service.WorkContactFormService;
import com.prd.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 工作联络单数据表 前端控制器
 * </p>
 *
 * @author lizhaoyi
 * @since 2023-11-06
 */
@Api(tags={"工作联络单"})
@RestController
@RequestMapping("/api/workContactForm")
public class WorkContactFormController {

    private WorkContactFormService workContactFormService;

    public WorkContactFormController(WorkContactFormService workContactFormService) {
        this.workContactFormService = workContactFormService;
    }

    @ApiOperation("分页查询工作单")
    @GetMapping("page")
    public JsonData selectPage(
            @ApiParam(value = "当前页")  @RequestParam(value = "page", defaultValue = "1") int page,
            @ApiParam(value = "每页显示多少条") @RequestParam(value = "size", defaultValue = "10") int size){

        return workContactFormService.selectPage(page,size);
    }

    @ApiOperation("新建工作联络单")
    @PostMapping("creat")
    public JsonData creatWorkOrder(@RequestBody WorkContactFormDTO workContactFormDTO){
        return workContactFormService.creatWorkOrder(workContactFormDTO);
    }

    @ApiOperation("查看工作联络单详情")
    @GetMapping("detail")
    public JsonData detail(@ApiParam(value = "工作联络单id") @RequestParam(value = "id") Long id,
                           @ApiParam(value = "用户id") @RequestParam(value = "userId") String userId){

        return workContactFormService.getDetail(id,userId);
    }

    @ApiOperation("取消联络单")
    @PostMapping("cancelContactForm")
    public JsonData cancelContactForm(@ApiParam(value = "工作联络单id") @RequestParam(value = "id") Long id){

        return workContactFormService.cancelContactForm(id);
    }

    @ApiOperation("增加抄送人")
    @PostMapping("addCC")
    public JsonData addCC(@ApiParam(value = "工作联络单id") @RequestParam(value = "id") Long id,
                                      @ApiParam(value = "抄送人id") @RequestParam(value = "userId") String userId){

        return workContactFormService.addCC(id,userId);
    }

    @ApiOperation("确定收到")
    @PostMapping("confirmReceipt")
    public JsonData confirmReceipt(@ApiParam(value = "工作联络单id") @RequestParam(value = "id") Long id){

        return workContactFormService.confirmReceipt(id);
    }

    @ApiOperation("办结回复")
    @PostMapping("completedResponse")
    public JsonData completedResponse(@ApiParam(value = "工作联络单对象") @RequestBody WorkContactFormDTO workContactFormDTO){

        return workContactFormService.completedResponse(workContactFormDTO);
    }

    @ApiOperation("安排执行人/由我执行")
    @PostMapping("setExecutor")
    public JsonData setExecutor(@ApiParam(value = "工作单id") @RequestParam("id")Long id
            ,@ApiParam(value = "执行人id") @RequestParam("userId") Long userId){

        return workContactFormService.setExecutor(id,userId);
    }

    @ApiOperation("执行汇报")
    @PostMapping("executionReport")
    public JsonData executionReport(@ApiParam(value = "工作单联络单对象") @RequestBody WorkContactFormDTO workContactFormDTO){

        return workContactFormService.executionReport(workContactFormDTO);
    }

    @ApiOperation("决算")
    @PostMapping("finalAccount")
    public JsonData finalAccount(@ApiParam(value = "工作单联络单对象") @RequestBody WorkContactFormDTO workContactFormDTO){

        return workContactFormService.finalAccount(workContactFormDTO);
    }

    @ApiOperation("安排督导人员/由我督导")
    @PostMapping("setWatcher")
    public JsonData setWatcher(@ApiParam(value = "工作单id") @RequestParam("id")Long id
            ,@ApiParam(value = "执行人id") @RequestParam("userId") Long userId){

        return workContactFormService.setWatcher(id,userId);
    }

    @ApiOperation("未达标/不合格")
    @PostMapping("notStandard")
    public JsonData notStandard(@ApiParam(value = "工作单联络单对象") WorkContactFormDTO workContactFormDTO){

        return workContactFormService.notStandard( workContactFormDTO);
    }

    @ApiOperation("达标/合格")
    @PostMapping("standard")
    public JsonData standard(@ApiParam(value = "工作单联络单对象") WorkContactFormDTO workContactFormDTO){

        return workContactFormService.standard( workContactFormDTO);
    }

    @ApiOperation("预算执行误差报告")
    @PostMapping("executionErrorReport")
    public JsonData executionErrorReport(@ApiParam(value = "工作单联络单对象") WorkContactFormDTO workContactFormDTO){

        return workContactFormService.executionErrorReport( workContactFormDTO);
    }

    @ApiOperation("预决算意见")
    @PostMapping("budgetOpinion")
    public JsonData budgetOpinion(@ApiParam(value = "工作单联络单对象") @RequestBody WorkContactFormDTO workContactFormDTO){

        return workContactFormService.budgetOpinion(workContactFormDTO);
    }

    @ApiOperation("预完成")
    @PostMapping("preComplete")
    public JsonData preComplete(@ApiParam(value = "工作单id") @RequestParam("id")Long id){

        return workContactFormService.preComplete(id);
    }

    @ApiOperation("已完成")
    @PostMapping("complete")
    public JsonData complete(@ApiParam(value = "工作单id") @RequestParam("id")Long id){

        return workContactFormService.complete(id);
    }

}

